package com.woniuxy.carlife.mapper;

import com.woniuxy.carlife.domain.ServiceAppraise;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.woniuxy.carlife.dto.AllAppraiseWithId;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author fx
 * @ClassName:ServiceAppraiseMapper
 * @Description: 门店服务评价mapper接口
 * @date 2021/4/6 20:00
 **/

public interface ServiceAppraiseMapper extends BaseMapper<ServiceAppraise> {

    /**
     * 功能描述〈根据用户id多表查询自己所有的评价,同时查询用户账号和头像对应的服务类别信息〉
     * @author:fx
     * @param: @param null:
     * @return:
     * @Date 2021/4/9 14:58
     * @throws
     */
    @Select("SELECT " +
            " sa.service_appraise_id, " +
            " sa.service_score, " +
            " sa.service_appraise_info, " +
            " sc.service_category_name, " +
            " sa.service_appraise_pic, " +
            " sa.appraise_create_time " +
            "FROM " +
            " t_service_appraise AS sa " +
            "JOIN t_service_info AS si  " +
            "ON sa.service_id = si.service_info_id " +
            "JOIN t_service_category AS sc  " +
            "ON si.service_category_id = sc.service_category_id " +
            "WHERE " +
            " sa.user_id = #{userId}")
    List<AllAppraiseWithId> findAllAppraiseByUserId(Integer userId);

    /**
     * 功能描述〈根据门店id查询该门店下的所有评论〉
     * @author:fx
     * @param: @param null:
     * @return:
     * @Date 2021/4/9 17:29
     * @throws
     */
    @Select("SELECT " +
            " sa.service_appraise_id, " +
            " sa.service_score, " +
            " sa.order_id, " +
            " sa.service_appraise_info, " +
            " sc.service_category_name, " +
            " sa.service_appraise_pic, " +
            " sa.appraise_create_time " +
            "FROM " +
            " t_service_appraise AS sa " +
            "JOIN t_service_info AS si  " +
            "ON sa.service_id = si.service_info_id " +
            "JOIN t_service_category AS sc  " +
            "ON si.service_category_id = sc.service_category_id " +
            "WHERE " +
            " sa.store_id = #{storeId}")
    List<AllAppraiseWithId> findAllAppraiseByStoreId(Integer storeId);
}
